config := meta.(*Config)

// current import_formats can't import fields with forward slashes in their value
if err := parseImportId([]string{"(?P<name>.+)"}, d, config); err != nil {
	return nil, err
}

parts := strings.Split(d.Get("name").(string), "/")

var projectId string
switch len(parts) {
	case 1:
		projectId = parts[0]
	case 2:
		projectId = parts[1]
	default:
		return nil, fmt.Errorf(
			"Saw %s when the name is expected to have shape %s or %s",
			d.Get("name"),
			"{{name}}",
			"organizations/{{name}}",
		)
}

if err := d.Set("name", projectId); err != nil {
	return nil, fmt.Errorf("Error setting organization: %s", err)
}

if err := d.Set("project_id", projectId); err != nil {
	return nil, fmt.Errorf("Error setting organization: %s", err)
}

// Replace import id for the resource id
id, err := replaceVars(d, config, "organizations/{{name}}")
if err != nil {
	return nil, fmt.Errorf("Error constructing id: %s", err)
}
d.SetId(id)

return []*schema.ResourceData{d}, nil
